package com.agua.enturno.vista.modelos;

import org.apache.wicket.model.IModel;
import org.joda.time.Duration;


public class DaysInNumberModel implements IModel<Integer> {
	
	private static final long serialVersionUID = 1L;
	
	private IModel<Duration> daysInDurationModel;
	
	public DaysInNumberModel(IModel<Duration> daysInDurationModel) {
		this.daysInDurationModel = daysInDurationModel;
	}

	@Override
	public void detach() {
		daysInDurationModel.detach();
	}

	@Override
	public Integer getObject() {
		return daysInDurationModel.getObject().toPeriod().getDays();
	}

	@Override
	public void setObject(Integer object) {
		this.daysInDurationModel.setObject(this.daysInDurationModel.getObject().toPeriod().withDays(object).toStandardDuration());
	}
	
}
